<?php

namespace App\model;

use Illuminate\Database\Eloquent\Model;

//管理员日志表
class AdminLogsModel extends Model
{
    //
    protected $table = 'admin_logs';

    protected $guarded = [];

    const UPDATED_AT = null;

    // public $timestamps = false;

    // 添加管理员日志
    public static function addLog($log, $uid = null) {
        if(session()->has('admin_id')){
            $data = [
                'admin_id' => session()->get('admin_id'),
                // 'uid' => $uid,
                'log' => $log,
                'method' => request()->method(),
                'ip' => request()->ip(),
                'agent' => request()->header('user-agent'),

            ];
            self::create($data);
            // self::insert($data);
        }
        
    }

    // 添加管理员日志
    public static function addLogs($log, $uid = null) {
        if(session()->has('shop_id')){
            $data = [
                'admin_id' => session()->get('shop_id'),
                // 'uid' => $uid,
                'log' => $log,
                'method' => request()->method(),
                'ip' => request()->ip(),
                'agent' => request()->header('user-agent'),

            ];
            self::create($data);
            // self::insert($data);
        }

    }

    // public function getAdminUserAttribute() {
    //     return $this->admin()->where('id',$this->admin_id)->value('user');
    // }

    // public function admin() {
    //     return $this->belongsTo('App\Model\AdminUserModel');
    // }

}
